import React, { Component } from 'react'
import { Link } from 'react-router-dom';
import qs from 'querystringify';

export default class NewsTabs extends Component {
  getQuery(search) {
    return qs.parse(search)
  }
  getString(search) {
    return qs.stringify(search)
  }
  render() {
    return (
      <ul className="section-news-tabs row justify-content-center text-center">
        {
          this.props.classify.map((item, i) => {
            const current = Object.assign({}, this.props.search, {cid: item.id, page: 1}),
            path = '/index/news?' + this.getString(current)
            return (
              <li key={i}>
                <Link onClick={(i) => this.selectTab} to={path} className={(this.props.cid === 0 && i === 0) || (item.id === this.props.cid) ? 'active' : ''}>{item.name}</Link>
              </li>
            )
          })
        }
      </ul>
    )
  }
}
